<?php

namespace Modules\Buy\Entities;

use Illuminate\Database\Eloquent\Model;

class Huowu extends Model
{
    protected $guarded = [];


//    组合属性，就是顶级属性加上子属性
    public function attrgroup($huowuid)
    {
        $huowu = Huowu::find($huowuid);
        $attr = $huowu->attr;
        $sonattr = [];
        foreach (explode(',',$attr) as $v){
            $sonattr[] = [
              'sonattr'=>Arr::find($v)->name,
                'attr'=>Arr::find($v)->attr->name,
            ];
        }
        return $sonattr;
    }



}